From: Matthew Daley Date: Sun, 1 Dec 2013 10:14:57 +0000 (+1300) Subject: libxl: correct file open success check in libxl__device_pci_reset X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~5832 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=3928e5ccdb6c3c4e1f5c6f0d61b3d6219a24d009;p=xen.git libxl: correct file open success check in libxl__device_pci_reset It could, even if only in theory, be fd 0. (This is not the same as commit 4b62556b57!) Coverity-ID: 1055895 Signed-off-by: Matthew Daley Acked-by: Ian Jackson --- diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c index c8eceb4a3b..095d5643d9 100644 --- a/tools/libxl/libxl_pci.c +++ b/tools/libxl/libxl_pci.c @@ -979,7 +979,7 @@ static int libxl__device_pci_reset(libxl__gc *gc, unsigned int domain, unsigned LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to access pciback path %s", reset); reset = libxl__sprintf(gc, "%s/"PCI_BDF"/reset", SYSFS_PCI_DEV, domain, bus, dev, func); fd = open(reset, O_WRONLY); - if (fd > 0) { + if (fd >= 0) { rc = write(fd, "1", 1); if (rc < 0) LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "write to %s returned %d", reset, rc);